package org.lanqiao.api.order;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.OrderListPOJO;
import org.lanqiao.service.OrderServiceImpl;

/**
 * 查询未付款订单
 * Servlet implementation class UnpaidsServlet
 */
@WebServlet("/api/order/UnpaidsServlet")
public class UnpaidsServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		/**
		 * 获取参数
		 */
			String userId=request.getParameter("orderUserId");
//			String userId="ccf6981d-9ef0-11e8-9e41-2c56dc0c08d9";
			/**
			 * 调用查询未付款订单
			 */
			OrderServiceImpl abc=new OrderServiceImpl();
			JsonResult result=null;
			try {
				List list=abc.Unpaids(userId);
				if(list!=null&list.size()>0){
					result=new JsonResult("查询成功",Constants.STATUS_SUCCESS,list);
				}else {
					result=new JsonResult("查询错误",Constants.STATUS_UNFOUND);
				}
			} catch (Exception e) {
				result=new JsonResult("查询异常",Constants.STATUS_FAILURE);
			}
			JsonResultWriter.writer(response, result);;
	}
}
